package Objects;

public class CRect {
	/************************************************************************/
	/*                          CLASS VARIABLES                             */
	/************************************************************************/
	private float left, top, bottom, right;
	/************************************************************************/
	/*                          CLASS PROPERTIES                            */
	/************************************************************************/
	public float getLeft() {
		return left;
	}

	public void setLeft(float left) {
		this.left = left;
	}

	public float getTop() {
		return top;
	}

	public void setTop(float top) {
		this.top = top;
	}

	public float getBottom() {
		return bottom;
	}

	public void setBottom(float bottom) {
		this.bottom = bottom;
	}

	public float getRight() {
		return right;
	}

	public void setRight(float right) {
		this.right = right;
	}
	/************************************************************************/
	/*                          CLASS CONSTRUCTOR                           */
	/************************************************************************/
	public CRect() {
		// TODO Auto-generated constructor stub
		this.left = this.top = this.bottom = this.right = 0;
	}
	
	public CRect(float fX, float fY, float fWidth, float fHeight) {
		this.left = fX;
		this.top = fY;
		this.bottom = fY + fHeight - 1;
		this.right = fX + fWidth - 1;
	}
	
	/************************************************************************/
	/*                          STATIC METHODS                              */
	/************************************************************************/
	// Check collision between 2 rect
	public static Boolean checkCollisionBetween2Rect(CRect a, CRect b) {
		if(a.bottom < b.top || 
			a.top > b.bottom || 
			a.right < b.left ||
			a.left > b.right) {
			return false;
		}
		return true;
	}
	
	// Check whether rect a stays inside rect b or not
	public static Boolean checkStayInsideAnotherRect(CRect a, CRect b) {
		if(a.bottom > b.bottom && 
		   a.top < b.top && 
		   a.left < b.left &&
		   a.right > b.right) {
			return true;
		}
		return false;
	}
}
